package com.alibaba.citrus.ots.unified.inventory.functions.allocateOrderDetail;

import com.alibaba.citrus.ots.common.util.SpringContextUtil;

import com.alibaba.citrus.ots.unified.inventory.repository.AllocateOrderDetailReadRepository;
import com.alibaba.citrus.ots.unified.inventory.repository.AllocateOrderDetailWriteRepository;
import com.epoch.app.otsunifiedinventory.sdo.AllocateOrderDetailSDO;
import lombok.Data;

/**
 * @description:
 * @author: yuhw
 * @date: 2021年09月18日 11:07
 **/
@Data
public class AllocateOrderDetailEntity {

    private AllocateOrderDetailSDO allocateOrderDetailSDO;

    private static AllocateOrderDetailReadRepository allocateOrderDetailReadRepository;
    private static AllocateOrderDetailWriteRepository allocateOrderDetailWriteRepository;

    static {
        allocateOrderDetailReadRepository = SpringContextUtil.getBean(AllocateOrderDetailReadRepository.class);
        allocateOrderDetailWriteRepository = SpringContextUtil.getBean(AllocateOrderDetailWriteRepository.class);
    }

    public static AllocateOrderDetailEntity of(AllocateOrderDetailSDO allocateOrderDetailSDO){
        AllocateOrderDetailEntity entity = new AllocateOrderDetailEntity();
        entity.setAllocateOrderDetailSDO(allocateOrderDetailSDO);
        return entity;
    }

    public String sync(){
        String id = allocateOrderDetailWriteRepository.sync(allocateOrderDetailSDO);
        return id;
    }

    public String salesOrderUpdate(){
        String id = allocateOrderDetailWriteRepository.sync(allocateOrderDetailSDO);
        return id;
    }

    public String create(){
//        allocateOrderDetailWriteRepository.
        String id = allocateOrderDetailWriteRepository.create(allocateOrderDetailSDO);
        return id;
    }
}
